<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>底部导航</title>
    <link rel="stylesheet" type="text/css" href="../../css/api1.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style1.css"/>
    <link rel="stylesheet" type="text/css" href="circle_style.css"/>
</head>
<body>
<div id="wrap" class="flex-wrap flex-vertical">

    <div class="answer" onclick="openResourceDetail()">
        <div id="resouce-box" class="resource" style="display:none">
            <div class="resource-left">
                <div id="resource-type" class="resource-imag">
                    PDF
                </div>
            </div>
            <div class="resource-right">
                <div id="resource-name" class="resource-name"></div>
                <div class="resource-note"></div>
                <div class="resource-note"></div>
            </div>
        </div>


    </div>
</div>
</body>
</html>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/jquery.js"></script>
<script type="text/javascript" src="../../script/dropload.min.js"></script>
<script type="text/javascript">
    var json_dict = {
        "app_version":"",
        "user_id":"",
        "user_cookie":"",
        "question_id":123,
        "answer_id":123,
        "since_id": 0,
        "page_size": 10
    };
    var json_data= {};

    apiready = function () {



        Getdata(json_dict);
        json_data.resouce_length = 5; //1-pdf 2-zip 3-rar
        // document.getElementById("resouce-box-0").childNodes[1].childNodes[1].innerHTML //这个是pdf字段
        // document.getElementById("resouce-box-0").childNodes[3].childNodes[1].innerHTML //这个是题目
        // document.getElementById("resouce-box-0").childNodes[3].childNodes[3].innerHTML //点赞数
        resouce_view();
    };
    function openResourceDetail() {
        api.openWin({
            name:'Resource_detail',
            url:'../QandA/resource_detail.html'
        })
    }

    function Getdata(json) {
        api.ajax({
            type: "post",
            url: "../../questionAnswer/getComment/",
            dataType : "json",
            data: JSON.stringify(json),
            success: function (d) {
                json_data = d; //是否需要将json转化为{}才能赋给json_data?
            }
        });
    }

    function resouce_view() {
        var sourceNode = document.getElementById("resouce-box"); // 获得被克隆的节点对象
        for (var i = 0; i < json_data.resouce_length; i++) {
            var clonedNode = sourceNode.cloneNode(true); // 克隆节点
            clonedNode.setAttribute("id", "resouce-box-" + i); // 修改一下id 值，避免id 重复
            sourceNode.parentNode.appendChild(clonedNode); // 在父节点插入克隆的节点
            clonedNode.style.display = '';
        }
        for (var i = 0; i < json_data.resouce_length; i++) {
            tmp = document.getElementById("resouce-box-" + i);
            tmp.childNodes[1].childNodes[1].innerHTML = 'RAR';
            tmp.childNodes[3].childNodes[1].innerHTML = '大物第一章习题';
            tmp.childNodes[3].childNodes[3].innerHTML = 1+'赞,';
            tmp.childNodes[3].childNodes[5].innerHTML = 0+'踩';
        }
    }




</script>
